<template>
  <div class="dashboard-page">
    <div class="page-header">
      <h1 class="page-title">仪表盘</h1>
    </div>
    
    <div class="dashboard-content">
      <el-row :gutter="20">
        <el-col :span="6">
          <el-card class="stat-card">
            <div class="stat-item">
              <div class="stat-icon products">
                <el-icon><Goods /></el-icon>
              </div>
              <div class="stat-content">
                <div class="stat-value">1,234</div>
                <div class="stat-label">商品总数</div>
              </div>
            </div>
          </el-card>
        </el-col>
        
        <el-col :span="6">
          <el-card class="stat-card">
            <div class="stat-item">
              <div class="stat-icon customers">
                <el-icon><UserFilled /></el-icon>
              </div>
              <div class="stat-content">
                <div class="stat-value">567</div>
                <div class="stat-label">客户总数</div>
              </div>
            </div>
          </el-card>
        </el-col>
        
        <el-col :span="6">
          <el-card class="stat-card">
            <div class="stat-item">
              <div class="stat-icon orders">
                <el-icon><ShoppingCart /></el-icon>
              </div>
              <div class="stat-content">
                <div class="stat-value">89</div>
                <div class="stat-label">订单总数</div>
              </div>
            </div>
          </el-card>
        </el-col>
        
        <el-col :span="6">
          <el-card class="stat-card">
            <div class="stat-item">
              <div class="stat-icon revenue">
                <el-icon><Money /></el-icon>
              </div>
              <div class="stat-content">
                <div class="stat-value">¥1,234,567</div>
                <div class="stat-label">总收入</div>
              </div>
            </div>
          </el-card>
        </el-col>
      </el-row>
      
      <el-row :gutter="20" style="margin-top: 20px;">
        <el-col :span="12">
          <el-card>
            <template #header>
              <span>最近订单</span>
            </template>
            <div class="recent-orders">
              <div v-for="order in recentOrders" :key="order.id" class="order-item">
                <div class="order-info">
                  <div class="order-number">{{ order.orderNumber }}</div>
                  <div class="order-customer">{{ order.customer }}</div>
                </div>
                <div class="order-amount">¥{{ order.amount }}</div>
              </div>
            </div>
          </el-card>
        </el-col>
        
        <el-col :span="12">
          <el-card>
            <template #header>
              <span>系统通知</span>
            </template>
            <div class="notifications">
              <div v-for="notification in notifications" :key="notification.id" class="notification-item">
                <div class="notification-icon">
                  <el-icon><Bell /></el-icon>
                </div>
                <div class="notification-content">
                  <div class="notification-title">{{ notification.title }}</div>
                  <div class="notification-time">{{ notification.time }}</div>
                </div>
              </div>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import { ref } from 'vue'
import { Goods, UserFilled, ShoppingCart, Money, Bell } from '@element-plus/icons-vue'

export default {
  name: 'Dashboard',
  components: {
    Goods, UserFilled, ShoppingCart, Money, Bell
  },
  setup() {
    const recentOrders = ref([
      { id: 1, orderNumber: 'ORD-001', customer: '科技设备公司', amount: '100,000' },
      { id: 2, orderNumber: 'ORD-002', customer: '电子科技公司', amount: '50,000' },
      { id: 3, orderNumber: 'ORD-003', customer: '智能设备公司', amount: '75,000' }
    ])
    
    const notifications = ref([
      { id: 1, title: '系统维护通知', time: '2小时前' },
      { id: 2, title: '新订单提醒', time: '4小时前' },
      { id: 3, title: '库存预警', time: '6小时前' }
    ])
    
    return {
      recentOrders,
      notifications
    }
  }
}
</script>

<style scoped>
.dashboard-page {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.page-header {
  margin-bottom: 20px;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.stat-card {
  border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 15px;
}

.stat-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
}

.stat-icon.products {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.stat-icon.customers {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-icon.orders {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-icon.revenue {
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.stat-content {
  flex: 1;
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.stat-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.recent-orders {
  max-height: 300px;
  overflow-y: auto;
}

.order-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-lighter);
}

.order-item:last-child {
  border-bottom: none;
}

.order-info {
  flex: 1;
}

.order-number {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.order-customer {
  font-size: 12px;
  color: var(--text-secondary);
}

.order-amount {
  font-weight: 600;
  color: var(--primary-color);
}

.notifications {
  max-height: 300px;
  overflow-y: auto;
}

.notification-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-lighter);
}

.notification-item:last-child {
  border-bottom: none;
}

.notification-icon {
  width: 32px;
  height: 32px;
  background: var(--background-base);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-color);
}

.notification-content {
  flex: 1;
}

.notification-title {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.notification-time {
  font-size: 12px;
  color: var(--text-secondary);
}
</style>